package com.example.demo.exception;

import com.example.demo.commen.AppResult;
import com.example.demo.commen.ResultCode;

/*
自定义的异常类*/

public class ApplicationException  extends  RuntimeException{

    protected AppResult errorAppResult;


    public  ApplicationException(AppResult errorAppResult){
        super(errorAppResult.getMessage());
        this.errorAppResult=errorAppResult;
    }
    public ApplicationException() {
        super();
    }

    public ApplicationException(String message) {
        super(message);
    }

    public ApplicationException(String message, Throwable cause) {
        super(message, cause);
    }

    public ApplicationException(Throwable cause) {
        super(cause);
    }
    public AppResult returnMessage(String message){

        this.errorAppResult.setCode(ResultCode.FAILED.getCode());
        this.errorAppResult.setMessage(message);

        return errorAppResult;
    }

    public AppResult getErrorAppResult() {
        return errorAppResult;
    }
}
